package com.itheima.prize.commons.db.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.prize.commons.db.entity.CardGame;
import com.itheima.prize.commons.db.service.CardGameService;
import com.itheima.prize.commons.db.mapper.CardGameMapper;
import com.itheima.prize.commons.utils.PageBean;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;

/**
* @author shawn
* @description 针对表【card_game】的数据库操作Service实现
* @createDate 2023-12-26 11:58:48
*/
@Service
public class CardGameServiceImpl extends ServiceImpl<CardGameMapper, CardGame>
    implements CardGameService{

    /**
     * 查询一分钟内要开始的活动
     * @return
     */
    @Override
    public List<CardGame> queryStartActivity() {

        //获取现在的时间和一分钟后的时间
        Date now = new Date();
        long time = now.getTime();
        Date nextTime = new Date();
        nextTime.setTime(time + 1000 * 60);

        //判断是否有活动在一分钟内开始并返回

        return lambdaQuery()
                .gt(CardGame::getStarttime, now)
                .le(CardGame::getStarttime, nextTime)
                .list();
    }
}




